package MyThread;

import java.util.concurrent.Semaphore;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: AliceMana
 * Date: 2023-01-12
 * Time: 16:30
 */
public class ThreadDemo31 {
    public static void main(String[] args) throws InterruptedException {
        Semaphore semaphore = new Semaphore(3);
        semaphore.acquire();
        System.out.println("执行一次P操作");
        semaphore.acquire();
        System.out.println("执行一次P操作");
        semaphore.acquire();
        System.out.println("执行一次P操作");
        semaphore.acquire();
        System.out.println("执行一次P操作");

        semaphore.release();
    }

}
